home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / exec / funfprin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  1.1 KB  |  56 lines

  1. /*
  2. \funcref{fun\_fprintf}{void fun\_fprintf ()}
  3.     {}
  4.     {}
  5.     {fprintf(), xrealloc()}
  6.     {fun\_exec()}
  7.     {funfprin.c}
  8.     {
  9.  
  10.         This function prints the arguments to a {\em fprint()} statement,
  11.         pushed onto the stack previously. The number of arguments to print is
  12.         the last pushed value.
  13.  
  14.         The arguments are: the number of arguments (a hidden parameter), a
  15.         filename, and then the remaining arguments to print.
  16.  
  17.     }
  18.  
  19. */
  20.  
  21. #include "icm-exec.h"
  22.  
  23. void fun_fprintf ()
  24. {
  25.     register int
  26.         i,
  27.         nargs;
  28.     int
  29.         newelement;
  30.     register char
  31.         *filename,
  32.         *space,
  33.         *string;
  34.     FILE
  35.         *outf;
  36.  
  37.     nargs = stack [sp].vu.intval;
  38.     filename = stack [sp - 1].vu.i->ls.str;
  39.  
  40.     if (! (outf = fopen (filename, "a")) )
  41.         error ("failure to open file \"%s\"", filename);
  42.  
  43.     for (i = 2; i <= nargs; i += newelement)
  44.     {
  45.         string = getarg (i, &newelement);
  46.         if (stack [sp - i].type & e_list && *string)
  47.             space = " ";
  48.         else
  49.             space = nullstring;
  50.         fprintf (outf, "%s%s", string, space);
  51.         xrealloc (string, 0);
  52.     }
  53.  
  54.     fclose (outf);
  55. }
  56.